RTS option
ghcで生成した実行ファイルを実行する時に指定する
実行時の統計を出力する
使っている例
code:hs
module Bar where
main :: IO ()
main = print $ fib 40
fib n = if n < 2 then 1 else fib (n - 1) + fib (n - 2)
$ stack ghc -- -main-is Bar src/Bar.hs -O2
$ ./Bar +RTS -s
code:result
λ ./src/Bar +RTS -s
165580141
7,947,930,784 bytes allocated in the heap
2,144,192 bytes copied during GC
44,376 bytes maximum residency (2 sample(s))
29,352 bytes maximum slop
2 MiB total memory in use (0 MB lost due to fragmentation)
Tot time (elapsed) Avg pause Max pause
Gen 0 7578 colls, 0 par 0.017s 0.034s 0.0000s 0.0000s
Gen 1 2 colls, 0 par 0.000s 0.000s 0.0001s 0.0001s
INIT time 0.000s ( 0.003s elapsed)
MUT time 4.288s ( 4.314s elapsed)
GC time 0.017s ( 0.034s elapsed)
EXIT time 0.000s ( 0.007s elapsed)
Total time 4.306s ( 4.358s elapsed)
%GC time 0.0% (0.0% elapsed)
Alloc rate 1,853,399,829 bytes per MUT second
Productivity 99.6% of total user, 99.0% of total elapsed